home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Programming / tek / visual.h < prev   
C/C++ Source or Header  |  2001-05-25  |  10KB  |  379 lines

  1.  
  2. #ifndef _TEK_VISUAL_H
  3. #define    _TEK_VISUAL_H
  4.  
  5. /*
  6. **    tek/visual.h
  7. **    visuals (prototype)
  8. **
  9. **    this section is considered experimental. there is no
  10. **    documentation available yet, you must refer to the
  11. **    example sources, and the comments in the respective
  12. **    functions' implementations (see visual/ for more details)
  13. **
  14. **    basic theory is as follows: 
  15. **
  16. **     - a 'visual' translates to a scalable window on currently
  17. **      supported platforms, but it may well translate to a
  18. **      fixed-size, double buffered chunk of memory in graphics
  19. **      hardware in the future.
  20. **    - any number of tasks may attach and draw to a visual,
  21. **      with no explicit locking required. only the creator
  22. **      may receive input events, though.
  23. **    - create a visual, and for each child task that needs
  24. **      to draw to it, call TAttachVisual(). use the handle
  25. **      returned by this function to draw to the visual in your
  26. **      current context. only the creator may use the handle
  27. **      returned from TCreateVisual() directly.
  28. **    - some drawing functions are blocking (or synchronous),
  29. **      others are nonblocking (or asychronous). use TVSync()
  30. **      to ensure that all drawing commands issued in your
  31. **      current context have been executed.
  32. **    - syncing does not imply that the visual or an area is
  33. **      actually exposed. to ensure that any modified buffers
  34. **      are exposed, use TVFlush() or TVFlushArea(). flush will
  35. **      synchronize also.
  36. */
  37.  
  38. #include <tek/msg.h>
  39.  
  40.  
  41. typedef TAPTR TVPEN;
  42.  
  43. typedef struct _tvisual
  44. {
  45.     THNDL handle;            /* object handle */
  46.  
  47.     TAPTR parenttask;        /* creator */
  48.     TAPTR task;                /* visual task */
  49.     TBOOL main;                /* is this the main instance? */
  50.     
  51.     TPORT *asyncport;        /* replyport for asynchronous drawjobs, and cache for free drawnodes */
  52.  
  53.  
  54.     /*    init data */
  55.  
  56.     TINT prefwidth, prefheight;
  57.     TSTRPTR preftitle;
  58.  
  59.  
  60.     /* main instance only: */
  61.  
  62.     TAPTR knvisual;            /* kernel visual */
  63.     TPORT *iport;            /* input port (parent context) */
  64.     TPORT *ireplyport;        /* input replyport (child context) */
  65.     
  66.     TKNOB lock;
  67.     TUINT refcount;
  68.  
  69.     /* attached instance only: */
  70.     
  71.     struct _tvisual *parentvisual;
  72.  
  73. } TVISUAL;
  74.  
  75.  
  76.  
  77. /*
  78. **    tag items.
  79. **
  80. */
  81.  
  82. #define TVISTAGS_                    (TTAG_USER + 0x600)
  83. #define TVisual_PixWidth            (TTAG) (TVISTAGS_ + 0)
  84. #define TVisual_PixHeight            (TTAG) (TVISTAGS_ + 1)
  85. #define TVisual_TextWidth            (TTAG) (TVISTAGS_ + 2)
  86. #define TVisual_TextHeight            (TTAG) (TVISTAGS_ + 3)
  87. #define TVisual_FontWidth            (TTAG) (TVISTAGS_ + 4)
  88. #define TVisual_FontHeight            (TTAG) (TVISTAGS_ + 5)
  89. #define TVisual_Title                (TTAG) (TVISTAGS_ + 6)
  90.  
  91.  
  92. #define TVISUAL_NUMDRMSG        200
  93. #define TVISUAL_NUMIMSG            200
  94.  
  95.  
  96. TBEGIN_C_API
  97.  
  98. extern TVISUAL *TCreateVisual(TAPTR task, TTAGITEM *tags)                                __ELATE_QCALL__(("qcall lib/tek/visual/createvisual"));
  99. extern TVISUAL *TAttachVisual(TAPTR task, TAPTR visual, TTAGITEM *tags)                    __ELATE_QCALL__(("qcall lib/tek/visual/attachvisual"));
  100. extern TVPEN TVAllocPen(TAPTR visual, TUINT rgb)                                        __ELATE_QCALL__(("qcall lib/tek/visual/allocpen"));
  101. extern TVOID TVFreePen(TAPTR visual, TVPEN pen)                                            __ELATE_QCALL__(("qcall lib/tek/visual/freepen"));
  102. extern TVOID TVRect(TAPTR visual, TINT x, TINT y, TINT w, TINT h, TVPEN pen)            __ELATE_QCALL__(("qcall lib/tek/visual/rect"));
  103. extern TVOID TVFRect(TAPTR visual, TINT x, TINT y, TINT w, TINT h, TVPEN pen)            __ELATE_QCALL__(("qcall lib/tek/visual/frect"));
  104. extern TVOID TVLine(TAPTR visual, TINT x1, TINT y1, TINT x2, TINT y2, TVPEN pen)        __ELATE_QCALL__(("qcall lib/tek/visual/line"));
  105. extern TVOID TVLineArray(TAPTR visual, TINT *array, TINT num, TVPEN pen)                __ELATE_QCALL__(("qcall lib/tek/visual/linearray"));
  106. extern TVOID TVPlot(TAPTR visual, TINT x, TINT y, TVPEN pen)                            __ELATE_QCALL__(("qcall lib/tek/visual/plot"));
  107. extern TVOID TVScroll(TAPTR visual, TINT x, TINT y, TINT w, TINT h, TINT dx, TINT dy)    __ELATE_QCALL__(("qcall lib/tek/visual/scroll"));
  108. extern TVOID TVClear(TAPTR visual, TVPEN pen)                                            __ELATE_QCALL__(("qcall lib/tek/visual/clear"));
  109. extern TVOID TVText(TAPTR visual, TINT x, TINT y, TSTRPTR text, TUINT len, TVPEN bgpen, TVPEN fgpen)    __ELATE_QCALL__(("qcall lib/tek/visual/text"));
  110. extern TVOID TVFlush(TAPTR visual)                                                        __ELATE_QCALL__(("qcall lib/tek/visual/flush"));
  111. extern TVOID TVFlushArea(TAPTR visual, TINT x, TINT y, TINT w, TINT h)                    __ELATE_QCALL__(("qcall lib/tek/visual/flusharea"));
  112. extern TVOID TVSync(TAPTR visual)                                                        __ELATE_QCALL__(("qcall lib/tek/visual/sync"));
  113. extern TUINT TVSetInput(TAPTR visual, TUINT clearmask, TUINT setmask)                    __ELATE_QCALL__(("qcall lib/tek/visual/setinput"));
  114. extern TVOID TVDrawRGB(TAPTR visual, TINT x, TINT y, TUINT *buffer, TINT w, TINT h, TINT totw)    __ELATE_QCALL__(("qcall lib/tek/visual/drawrgb"));
  115. extern TUINT TVGetAttrs(TAPTR visual, TTAGITEM *tags)                                    __ELATE_QCALL__(("qcall lib/tek/visual/getattrs"));
  116.  
  117.  
  118. TEND_C_API
  119.  
  120.  
  121. #define TVJOB_ALLOCPEN        0
  122. #define TVJOB_FREEPEN        1
  123. #define TVJOB_PLOT            2
  124. #define TVJOB_RECT            3
  125. #define TVJOB_FRECT            4
  126. #define TVJOB_LINE            5
  127. #define TVJOB_SCROLL        6
  128. #define TVJOB_CLEAR            7
  129. #define TVJOB_TEXT            8
  130. #define TVJOB_FLUSH            9
  131. #define TVJOB_LINEARRAY        10
  132. #define TVJOB_SETINPUT        11
  133. #define TVJOB_SYNC            12
  134. #define TVJOB_DRAWRGB        13
  135. #define TVJOB_FLUSHAREA        14
  136. #define TVJOB_GETATTRS        15
  137.  
  138.  
  139. typedef struct
  140. {
  141.     TUINT jobcode;
  142.     
  143.     union
  144.     {
  145.         struct
  146.         {
  147.             TUINT rgb;
  148.             TVPEN pen;
  149.         } rgbpen;
  150.  
  151.         struct
  152.         {
  153.             TVPEN pen;
  154.         } pen;
  155.     
  156.         struct
  157.         {
  158.             TINT x,y;
  159.             TVPEN pen;
  160.         } plot;
  161.  
  162.         struct
  163.         {
  164.             TINT x,y;
  165.             TINT w,h;
  166.         } rect;
  167.  
  168.         struct
  169.         {
  170.             TINT x,y;
  171.             TINT w,h;
  172.             TVPEN pen;
  173.         } colrect;
  174.  
  175.         struct
  176.         {
  177.             TINT x,y;
  178.             TINT w,h;
  179.             TINT dx,dy;
  180.         } scroll;
  181.                 
  182.         struct
  183.         {
  184.             TINT x,y;
  185.             TSTRPTR text;
  186.             TUINT len;
  187.             TVPEN bgpen, fgpen;
  188.         } text;
  189.  
  190.         struct
  191.         {
  192.             TINT *array;
  193.             TINT num;
  194.             TVPEN pen;
  195.         } array;
  196.         
  197.         struct
  198.         {
  199.             TUINT setmask;
  200.             TUINT clearmask;
  201.             TUINT oldmask;
  202.         } input;
  203.  
  204.         struct
  205.         {
  206.             TUINT *rgbbuf;
  207.             TINT x,y;
  208.             TINT w,h,totw;
  209.         } rgb;
  210.  
  211.         struct
  212.         {
  213.             TINT pixwidth, pixheight;
  214.             TINT fontwidth, fontheight;
  215.             TINT textwidth, textheight;
  216.         } attrs;
  217.  
  218.     } op;
  219.  
  220. } TDRAWMSG;
  221.  
  222.  
  223.  
  224.  
  225.  
  226. /*
  227. **    input message
  228. */
  229.  
  230. typedef struct
  231. {
  232.     TUINT type;                        /* input type (see below) */
  233.     TUINT code;                        /* input code */
  234.     TUINT qualifier;                /* keyboard qualifier */
  235.     TINT mousex, mousey;            /* mouse position */
  236.     TINT width, height;                /* window dimensions */
  237.  
  238. } TIMSG;
  239.  
  240.  
  241.  
  242.  
  243.  
  244. /*
  245. **    input types
  246. */
  247.  
  248. #define TITYPE_NONE                0x00000000
  249. #define TITYPE_ALL                0xffffffff
  250.  
  251. #define TITYPE_VISUAL_CLOSE        0x00000001        /* close button */
  252. #define TITYPE_VISUAL_FOCUS        0x00000002        /* visual gets focus */
  253. #define TITYPE_VISUAL_UNFOCUS    0x00000004        /* visual is unfocused */
  254. #define TITYPE_VISUAL_NEWSIZE    0x00000008        /* visual is resized */
  255. #define    TITYPE_KEY                0x00000010        /* keystroke (codes see below) */
  256. #define TITYPE_MOUSEMOVE        0x00000020        /* mouse movement */
  257. #define TITYPE_MOUSEBUTTON        0x00000040        /* mouse button (codes see below) */
  258.  
  259.  
  260.  
  261. /*
  262. **    mouse button codes
  263. */
  264.  
  265. #define TMBCODE_LEFTDOWN        0x00000001
  266. #define TMBCODE_LEFTUP            0x00000002
  267. #define TMBCODE_RIGHTDOWN        0x00000004
  268. #define TMBCODE_RIGHTUP            0x00000008
  269. #define TMBCODE_MIDDLEDOWN        0x00000010
  270. #define TMBCODE_MIDDLEUP        0x00000020
  271.  
  272.  
  273.  
  274. /*
  275. **    function key codes
  276. */
  277.  
  278. #define TKEYCODE_F1                0x00000100
  279. #define TKEYCODE_F2                0x00000101
  280. #define TKEYCODE_F3                0x00000102
  281. #define TKEYCODE_F4                0x00000103
  282. #define TKEYCODE_F5                0x00000104
  283. #define TKEYCODE_F6                0x00000105
  284. #define TKEYCODE_F7                0x00000106
  285. #define TKEYCODE_F8                0x00000107
  286. #define TKEYCODE_F9                0x00000108
  287. #define TKEYCODE_F10            0x00000109
  288. #define TKEYCODE_F11            0x0000010a
  289. #define TKEYCODE_F12            0x0000010b
  290.  
  291.  
  292. /*
  293. **    cursor key codes
  294. */
  295.  
  296. #define    TKEYCODE_CRSRLEFT        0x00000200
  297. #define    TKEYCODE_CRSRRIGHT        0x00000201
  298. #define    TKEYCODE_CRSRUP            0x00000202
  299. #define    TKEYCODE_CRSRDOWN        0x00000203
  300.  
  301.  
  302. /*
  303. **    special key codes
  304. */
  305.  
  306. #define TKEYCODE_ESC            0x00000300    /* escape key */
  307. #define TKEYCODE_DEL            0x00000301    /* del key */
  308. #define TKEYCODE_BCKSPC            0x00000302    /* backspace key */
  309. #define TKEYCODE_TAB            0x00000303    /* tab key */
  310. #define TKEYCODE_ENTER            0x00000304    /* return/enter */
  311.  
  312.  
  313. /*
  314. **    proprietary key codes
  315. **
  316. **    style guide note:
  317. **
  318. **    whenever your application binds actions to a key from this section,
  319. **    you should offer at least one non-proprietary alternative.
  320. **
  321. **    example: use TKEYQUAL_CONTROL + TKEYCODE_CRSRRIGHT as an alternative
  322. **    to TKEYCODE_POSEND, etc.
  323. **
  324. **    the same applies to the keyboard qualifier TKEYQUAL_PROPRIETARY
  325. **    (see below)
  326. **
  327. */
  328.  
  329. #define TKEYCODE_HELP            0x00000400    /* help key (amiga) */
  330. #define TKEYCODE_INSERT            0x00000401    /* insert key (pc) */
  331. #define TKEYCODE_OVERWRITE        0x00000402    /* overwrite key (pc) */
  332. #define    TKEYCODE_PAGEUP            0x00000403    /* page up (pc) */
  333. #define    TKEYCODE_PAGEDOWN        0x00000404    /* page down (pc) */
  334. #define TKEYCODE_POSONE            0x00000405    /* position one key (pc) */
  335. #define TKEYCODE_POSEND            0x00000406    /* position end key (pc) */
  336. #define TKEYCODE_PRINT            0x00000407    /* print key (pc) */
  337. #define TKEYCODE_SCROLL            0x00000408    /* scroll down (pc) */
  338. #define TKEYCODE_PAUSE            0x00000409    /* pause key (pc) */
  339.  
  340.  
  341. /*
  342. **    keyboard qualifiers
  343. **
  344. **    style guide notes:
  345. **
  346. **    your application's default or hardcoded key bindings should not
  347. **    rely on TKEYCODE_PROPRIETARY, nor on the LEFT/RIGHT modifiers.
  348. **    usage of the TKEYQUAL_NUMBLOCK qualifier without alternatives
  349. **    is disencouraged, too.
  350. **
  351. */
  352.  
  353. #define    TKEYQUAL_NONE                0x0000    /* no qualifier */
  354. #define TKEYQUAL_LEFT                0x0001    /* left modifier */
  355. #define TKEYQUAL_RIGHT                0x0002    /* right modifier */
  356.  
  357. #define TKEYQUAL_SHIFT                0x0004    /* shift qualifier */
  358. #define TKEYQUAL_LEFT_SHIFT            (TKEYQUAL_SHIFT | TKEYQUAL_LEFT)
  359. #define TKEYQUAL_RIGHT_SHIFT        (TKEYQUAL_SHIFT | TKEYQUAL_RIGHT)
  360.  
  361. #define TKEYQUAL_CONTROL            0x0008    /* control qualifier */
  362. #define TKEYQUAL_LEFT_CONTROL        (TKEYQUAL_CONTROL | TKEYQUAL_LEFT)
  363. #define TKEYQUAL_RIGHT_CONTROL        (TKEYQUAL_CONTROL | TKEYQUAL_RIGHT)
  364.  
  365. #define TKEYQUAL_ALT                0x0010    /* alt qualifier */
  366. #define TKEYQUAL_LEFT_ALT            (TKEYQUAL_ALT | TKEYQUAL_LEFT)
  367. #define TKEYQUAL_RIGHT_ALT            (TKEYQUAL_ALT | TKEYQUAL_RIGHT)
  368.  
  369. #define    TKEYQUAL_PROPRIETARY        0x0020    /* amiga, apple, windows etc. key */
  370. #define TKEYQUAL_LEFT_PROPRIETARY    (TKEYQUAL_PROPRIETARY | TKEYQUAL_LEFT)
  371. #define TKEYQUAL_RIGHT_PROPRIETARY    (TKEYQUAL_PROPRIETARY | TKEYQUAL_RIGHT)
  372.  
  373. #define TKEYQUAL_NUMBLOCK            0x0040    /* numeric keypad qualifier */
  374.  
  375.  
  376.  
  377. #endif
  378.  
  379.